#!/bin/bash

## Copyright (C) 2019 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

## https://serverfault.com/questions/134471/success-n-control-syntax-in-pam-conf-pam-d-files

set -x
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
shopt -s inherit_errexit
shopt -s shift_verbose

true "PAM_SERVICE: ${PAM_SERVICE:-}"

if [ "${PAM_SERVICE:-}" = "login" ]; then
   ## FIXME:
   ## Creates unwanted journal log entry.
   ## pam_exec(login:account): /usr/libexec/security-misc/pam_only_if_login failed: exit code 1
   exit 1
else
   ## exit success so [success=1 default=ignore] will result in skipping the
   ## next pam module.
   exit 0
fi
